package com.liuceng.zen.service;

import com.liuceng.zen.mapper.ApplicationMapper;
import com.liuceng.zen.pojo.domain.Application;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by lijunhao on 16-11-25.
 */
@Service
public class ApplicationService extends BaseService<Application>{
    @Autowired
    ApplicationMapper applicationMapper;

    @Transactional(readOnly = true)
    public boolean companyNameExists(String companyName) {
        return applicationMapper.countApplicationsByCompanyName(companyName) > 0 ? true : false;
    }

    @Transactional
    public void addApplication(Application application){
        application.setType(0);
        super.insert(application);
    }
}
